import request from '@/utils/request'

// 安全时段总览 or 查询
export function safeOverview() {
  return request({
    url: '/safetytime',
    method: 'post',
    data: {
      access_token: 'token_950000100',
      type: 'safetytime_get_condition',
      pid: 'default',
      data: {
        condition: {
          name: ''
        },
        page: {
          page_size: '10',
          page_number: '1'
        }
      }
    }
  })
}

// 增加安全时段
export function increaseSafe(token) {
  return request({
    url: '/safetytime',
    method: 'post',
    data: {
      access_token: 'access_tokenxxxxxxxx',
      type: 'add_safetytime',
      pid: 'default',
      data: {
        name: '999',
        status: 0,
        equips: ['1','1.wsd0001','1.wsd0001.1','1.wsd0001.2'],
        times: [{
          begin_time: '2017-09-15 15:00:00',
          end_time: '2017-09-15 18:00:00',
          week: ['1']
        }]
      }
    }
  })
}

// 删除安全时段
export function deleteSite(id, token) {
  return request({
    url: '/safetytime',
    method: 'post',
    data: {
      access_token: 'access_tokenxxxxxxxx',
      type: 'del_safetytime',
      pid: 'default',
      ids: [1,2]
    }
  })
}

// 修改安全时段
export function editSite(id, token) {
  return request({
    url: '/safetytime',
    method: 'post',
    data: {
      access_token: 'access_tokenxxxxxxxx',
      type: 'mod_safetytime',
      pid: 'default',
      data: {
        id: 3,
        name: '时段2',
        status: 1,
        equips: ['default',
          'default.plc0001',
          'default.plc0001.QSP001',
          'default.plc0001.QSP002'],
        times: [{
          begin_time: '2017-09-15 15:00:00',
          end_time: '2017-09-15 18:00:00',
          week: ['1']
        }]
      }
    }
  })
}

// 查看安全时段
export function lookSite(id, token) {
  return request({
    url: '/safetytime',
    method: 'post',
    data: {
      access_token: 'access_tokenxxxxxxxx',
      type: 'get_safetytime_byid',
      pid: 'default',
      id: 6
    }
  })
}
